import Vue from 'vue'
import Router from 'vue-router'
import Home from '#/home'
import City from '#/city'
import FilmList from '#/film/list'
import FilmDetail from '#/film/detail'
import FilmSearch from '#/film/FilmSearch'
import Cinema from '#/cinema'
import Mine from '#/mine'
import HelloWorld from '@/components/HelloWorld'
import store from '@/store'
Vue.use(Router)

const router = new Router({
  routes: [
    {
      path: '/',
      name: 'Home',
      component: Home,
      redirect: '/film',
      children: [
        { path: 'film', component: FilmList },
        { path: 'cinema', component: Cinema },
        { path: 'mine', component: Mine }
      ]
    },
    {
      path: '/film/detail/:movieId',
      name: 'FilmDetail',
      component: FilmDetail
    },
    {
      path: '/search',
      name: 'filmSearch',
      component: FilmSearch
    },
    {
      path: '/city',
      name: 'city',
      component: City
    },
    {
      path: '/hello',
      name: 'hello',
      component: HelloWorld
    }
  ]
})
export default router
router.beforeEach((to, from, next) => {
  store.dispatch('toggleTab', to.path)
  next()
})
router.afterEach(() => {

})
